
import Home from '@/layout/Home.vue'

export const routes =[
    {
        path: '/home',
        name: 'Home',
        redirect:"/home/info", //自动重定向
        component: Home,
        beforeEnter: (to, from, next) => {
          // 判断是否有token进行拦截跳转 实现对所有页面进行权限控制
          if(true){
            next()
          }else{
            next("/login")
          }
        },
        children:[{
          path:"info",
          name:"用户信息",
          component:() => import(/* webpackChunkName: "about" */ '../views/userinfo.vue')
        }
          // 登陆后才能访问的页面都在此添加
      
      ]
      },
      // 无需登陆就能看的页面
      {
        path: '/login',
        name: 'Login',
        beforeEnter: (to, from, next) => {
          // 已经登陆则拦截不跳转
          if(true){
            next("/home")
          }
        },
        component: () => import(/* webpackChunkName: "about" */ '../views/Login.vue')
      },{
        path: '*',
        redirect:"/home", //自动重定向到首页
      }

]